package com.jxwifi.cloud.quickclean.app;

import android.content.Context;
import android.util.Log;

import com.alibaba.sdk.android.push.MessageReceiver;
import com.alibaba.sdk.android.push.notification.CPushMessage;
import com.jxwifi.cloud.quickclean.orderdetails.OrderStatusListener;

import java.util.Map;

/**
 * Created by Administrator on 2019/5/22.
 */

public class  MyMessageReceiver extends MessageReceiver {

    private String TAG = this.getClass().getSimpleName();
    // 消息接收部分的LOG_TAG
    public static final String REC_TAG = "receiver";

    OrderStatusListener listener;

    public MyMessageReceiver(){
        super();
    }
    /*public MyMessageReceiver(OrderStatusListener orderStatusListener){
        listener = orderStatusListener;
        Log.i(TAG,"listener = "+listener);
    }*/

    //通知显示处理
    @Override
    public void onNotification(Context context, String title, String summary, Map<String, String> extraMap) {
        // TODO 处理推送通知
        Log.e("MyMessageReceiver", "Receive notification, title: " + title + ", summary: " + summary + ", extraMap: " + extraMap);
        //Log.i(TAG,"onNotification ==> listener = "+listener);
        if(null != listener && !title.equals("退款通知")){
            listener.getOrderStatus(summary);
        }
    }
    /** * 监听广播接收器的接收到的数据 * @param updateUIListenner */
    public void SetOrderStatusListenner(OrderStatusListener orderStatusListener) {
        this.listener = orderStatusListener;
        Log.i(TAG,"SetOrderStatusListenner ==> listener = "+listener);
    }

    @Override
    public void onMessage(Context context, CPushMessage cPushMessage) {
        Log.e("MyMessageReceiver", "onMessage, messageId: " + cPushMessage.getMessageId() + ", title: " + cPushMessage.getTitle() + ", content:" + cPushMessage.getContent());
    }
    //消息点击处理
    @Override
    public void onNotificationOpened(Context context, String title, String summary, String extraMap) {
        Log.e("MyMessageReceiver", "onNotificationOpened, title: " + title + ", summary: " + summary + ", extraMap:" + extraMap);
    }

    @Override
    protected void onNotificationClickedWithNoAction(Context context, String title, String summary, String extraMap) {
        Log.e("MyMessageReceiver", "onNotificationClickedWithNoAction, title: " + title + ", summary: " + summary + ", extraMap:" + extraMap);
    }

    @Override
    protected void onNotificationReceivedInApp(Context context, String title, String summary, Map<String, String> extraMap, int openType, String openActivity, String openUrl) {
        Log.e("MyMessageReceiver", "onNotificationReceivedInApp, title: " + title + ", summary: " + summary + ", extraMap:" + extraMap + ", openType:" + openType + ", openActivity:" + openActivity + ", openUrl:" + openUrl);
    }
    @Override
    protected void onNotificationRemoved(Context context, String messageId) {
        Log.e("MyMessageReceiver", "onNotificationRemoved");
    }

}
